package com.wr.services.impl;

import com.wr.mappers.PersonalEntityMapper;
import com.wr.pojos.PersonalEntity;
import com.wr.services.PersonalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2016/11/18 0018.
 */
@Service
public class PersonalServiceImpl implements PersonalService {

    @Autowired
    private PersonalEntityMapper personalEntityMapper;

    @Override
    public void insertPersonalInfo(PersonalEntity personalEntity) {

        personalEntityMapper.insert(personalEntity);
    }

    @Override
    public void updatePersonalInfo(PersonalEntity personalEntity) {

        personalEntityMapper.updateByPrimaryKeySelective(personalEntity);
    }

    @Override
    public PersonalEntity getPersonalInfo(String userId) {
        List<PersonalEntity> list = personalEntityMapper.selectPersonalByUserId(userId);
        if(list.size() > 0){
            return list.get(0);
        }
        return null;
    }

    @Override
    public PersonalEntity getPersonalInfoById(int id) {
        return personalEntityMapper.selectByPrimaryKey(id);
    }
}
